package com.itheima.d8BSDemo;

import java.io.IOException;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.Socket;

public class MyRunnable implements Runnable{
    private Socket socket;
    public MyRunnable(Socket socket){
        this.socket = socket;
    }
    @Override
    public void run() {
        OutputStream outputStream = null;
        try {
            outputStream = socket.getOutputStream();
            PrintStream printStream = new PrintStream(outputStream);
            printStream.println("HTTP/1.1 200 OK");
            printStream.println("Content-Type:text/html;charset=UTF-8");
            printStream.println(); //必须换一行
            printStream.println("<div>This is</div>");
            printStream.close(); //关闭
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
}
